package weixin.core.controller;

import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by lxb on 2017/4/13.
 */
@Controller
@RequestMapping("test3")
public class TestController {
    @Autowired
    private RuntimeService runtimeService;
    @Autowired
    private TaskService taskService;
    @RequestMapping("start")
    @ResponseBody
    public String startProcess(){
        ProcessInstance instance=runtimeService.startProcessInstanceByKey("myProcess_1");
        // 根据流程实例获取任务id
        String taskId = taskService.createTaskQuery().processInstanceId(instance.getProcessInstanceId()).singleResult().getId();
        taskService.complete(taskId);
        return "1111";
    }
}
